





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.relay.image &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
        <script src="../../../../_static/jquery.js"></script>
        <script src="../../../../_static/underscore.js"></script>
        <script src="../../../../_static/doctools.js"></script>
        <script src="../../../../_static/translations.js"></script>
        <script async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    
    <script type="text/javascript" src="../../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../../search.html" />
    <link rel="next" title="tvm.relay.transform" href="transform.html" />
    <link rel="prev" title="tvm.relay.vision" href="vision.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../../index.html">
          

          
            
            <img src="../../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="../error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../target.html">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="../te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="../driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="../auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="../contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="../graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="../topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="../index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.relay.image</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../../_sources/reference/api/python/relay/image.rst.txt" rel="nofollow"> <img src="../../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.relay.image">
<span id="tvm-relay-image"></span><h1>tvm.relay.image<a class="headerlink" href="#module-tvm.relay.image" title="永久链接至标题">¶</a></h1>
<p>Image network related operators.</p>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.image.affine_grid" title="tvm.relay.image.affine_grid"><code class="xref py py-obj docutils literal notranslate"><span class="pre">affine_grid</span></code></a>(data[, target_shape])</p></td>
<td><p>affine_grid operator that generates 2D sampling grid.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.image.crop_and_resize" title="tvm.relay.image.crop_and_resize"><code class="xref py py-obj docutils literal notranslate"><span class="pre">crop_and_resize</span></code></a>(data, boxes, box_indices, …)</p></td>
<td><p>裁剪并调整输入图像的大小。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.image.dilation2d" title="tvm.relay.image.dilation2d"><code class="xref py py-obj docutils literal notranslate"><span class="pre">dilation2d</span></code></a>(data, weight[, strides, padding, …])</p></td>
<td><p>2D 形态学膨胀。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.image.grid_sample" title="tvm.relay.image.grid_sample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">grid_sample</span></code></a>(data, grid[, method, layout])</p></td>
<td><p>Applies bilinear sampling to input feature map.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.image.resize1d" title="tvm.relay.image.resize1d"><code class="xref py py-obj docutils literal notranslate"><span class="pre">resize1d</span></code></a>(data, size[, layout, method, …])</p></td>
<td><p>图像 1 维重塑算子。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.relay.image.resize2d" title="tvm.relay.image.resize2d"><code class="xref py py-obj docutils literal notranslate"><span class="pre">resize2d</span></code></a>(data, size[, layout, method, …])</p></td>
<td><p>图像 2 维重塑算子。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.relay.image.resize3d" title="tvm.relay.image.resize3d"><code class="xref py py-obj docutils literal notranslate"><span class="pre">resize3d</span></code></a>(data, size[, layout, method, …])</p></td>
<td><p>图像 3 维重塑算子。</p></td>
</tr>
</tbody>
</table>
<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.affine_grid">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">affine_grid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.affine_grid" title="永久链接至目标">¶</a></dt>
<dd><p>affine_grid operator that generates 2D sampling grid.</p>
<p>This operation is described in <a class="reference external" href="https://arxiv.org/pdf/1506.02025.pdf">https://arxiv.org/pdf/1506.02025.pdf</a>. It generates a uniform
sampling grid within the target shape and normalizes it to [-1, 1]. The provided affine
transformation is then applied on the sampling grid.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>tvm.Tensor</em>) – 3-D with shape [batch, 2, 3]. The affine matrix.</p></li>
<li><p><strong>target_shape</strong> (<em>list/tuple of two int</em>) – Specifies the output shape (H, W).</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>Output</strong> – 4-D with shape [batch, 2, target_height, target_width]</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.Tensor</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.crop_and_resize">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">crop_and_resize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">boxes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">box_indices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">crop_size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'bilinear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">extrapolation_value</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.crop_and_resize" title="永久链接至目标">¶</a></dt>
<dd><p>裁剪并调整输入图像的大小。</p>
<p>method indicates the algorithm to be used while calculating the out value
and method can be either “bilinear” or “nearest_neighbor”.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>relay.Expr</em>) – The input data to the operator.</p></li>
<li><p><strong>boxes</strong> (<em>relay.Expr</em>) – A 2-D tensor of shape [num_boxes, 4]. Each row of the tensor specifies
the coordinates of a box.</p></li>
<li><p><strong>box_indices</strong> (<em>relay.Expr</em>) – A 1-D tensor of shape [num_boxes], box_ind[i] specifies the data that
the i-th box refers to.</p></li>
<li><p><strong>crop_size</strong> (<em>Tuple of PrimExpr</em>) – The target size to which each box will be resized.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Layout of the input.</p></li>
<li><p><strong>method</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Scale method, it can be either “nearest_neighbor” or “bilinear”.</p></li>
<li><p><strong>extrapolation_value</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a><em>, </em><em>optional</em>) – Value used for extrapolation, when applicable.</p></li>
<li><p><strong>out_dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Type to return. If left None returns the same type as input.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The computed result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>relay.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.dilation2d">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">dilation2d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weight</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">strides</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">padding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(0,</span> <span class="pre">0)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dilations</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1,</span> <span class="pre">1)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data_layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">kernel_layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'IHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.dilation2d" title="永久链接至目标">¶</a></dt>
<dd><p>Morphological Dilation 2D.
This operator takes the weight as the dilation kernel and dilates it with
data to produce an output. In the default case, where the data_layout is <cite>NCHW</cite>
and kernel_layout is <cite>OIHW</cite>, dilation2d takes in a data Tensor with shape
<cite>(batch_size, in_channels, height, width)</cite>, and a weight Tensor with shape
<cite>(channels, kernel_height, kernel_width)</cite> to produce an output Tensor
with the following rule:</p>
<div class="math notranslate nohighlight">
\[\mbox{out}[b, c, y, x] = \max_{dy, dx}
   \mbox{data}[b, c, \mbox{strides}[0] * y  + dy, \mbox{strides}[1] * x + dx] +
   \mbox{weight}[c, dy, dx]\]</div>
<p>Padding and dilation are applied to data and weight respectively before the computation.
This operator accepts data layout specification. Semantically, the operator
will convert the layout to the canonical layout
(<cite>NCHW</cite> for data and <cite>IHW</cite> for weight) and perform the computation.</p>
<dl class="simple">
<dt>weight<span class="classifier">tvm.relay.Expr</span></dt><dd><p>The weight expressions.</p>
</dd>
<dt>strides<span class="classifier">Optional[Tuple[int]]</span></dt><dd><p>The strides of convolution.</p>
</dd>
<dt>padding<span class="classifier">Optional[Tuple[int]]</span></dt><dd><p>The padding of convolution on both sides of inputs before convolution.</p>
</dd>
<dt>dilations<span class="classifier">Optional[Tuple[int]]</span></dt><dd><p>Specifies the dilation rate to be used for dilated convolution.</p>
</dd>
<dt>data_layout<span class="classifier">Optional[str]</span></dt><dd><p>Layout of the input.</p>
</dd>
<dt>kernel_layout<span class="classifier">Optional[str]</span></dt><dd><p>Layout of the weight.</p>
</dd>
<dt>out_dtype<span class="classifier">Optional[str]</span></dt><dd><p>Specifies the output data type.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>result</strong> – The computed result.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>tvm.relay.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.grid_sample">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">grid_sample</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">grid</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'bilinear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.grid_sample" title="永久链接至目标">¶</a></dt>
<dd><p>Applies bilinear sampling to input feature map.</p>
<p>Given <span class="math notranslate nohighlight">\(data\)</span> and <span class="math notranslate nohighlight">\(grid\)</span>, then the output is computed by</p>
<div class="math notranslate nohighlight">
\[x_{src} = grid[batch, 0, y_{dst}, x_{dst}] \
y_{src} = grid[batch, 1, y_{dst}, x_{dst}] \
output[batch, channel, y_{dst}, x_{dst}] = G(data[batch, channel, y_{src}, x_{src})\]</div>
<p><span class="math notranslate nohighlight">\(x_{dst}\)</span>, <span class="math notranslate nohighlight">\(y_{dst}\)</span> enumerate all spatial locations in <span class="math notranslate nohighlight">\(output\)</span>, and
<span class="math notranslate nohighlight">\(G()\)</span> denotes the interpolation function.
The out-boundary points will be padded with zeros. The shape of the output will be
(data.shape[0], data.shape[1], grid.shape[2], grid.shape[3]).</p>
<p>The operator assumes that <span class="math notranslate nohighlight">\(grid\)</span> has been normalized to [-1, 1].</p>
<p>grid_sample often cooperates with affine_grid which generates sampling grids for grid_sample.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>tvm.Tensor</em>) – 4-D with shape [batch, in_channel, in_height, in_width]</p></li>
<li><p><strong>grid</strong> (<em>tvm.Tensor</em>) – 4-D with shape [batch, 2, out_height, out_width]</p></li>
<li><p><strong>method</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The interpolation method. Only ‘bilinear’ is supported.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The layout of input data and the output.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>Output</strong> – 4-D with shape [batch, 2, out_height, out_width]</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>tvm.Tensor</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.resize1d">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">resize1d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'linear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coordinate_transformation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'half_pixel'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rounding_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_exclude</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.resize1d" title="永久链接至目标">¶</a></dt>
<dd><p>图像 1 维重塑算子。</p>
<p>This operator takes data as input and does 1D scaling to the given scale factor.
In the default case, where the data_layout is <cite>NCW</cite>
with data of shape (n, c, w)
out will have a shape (n, c, size[0])</p>
<p>method indicates the algorithm to be used while calculating the out value
and method can be one of (“linear”, “nearest_neighbor”, “cubic”)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>relay.Expr</em>) – The input data to the operator.</p></li>
<li><p><strong>size</strong> (<em>Tuple of Int</em><em> or </em><em>Expr</em>) – The out size to which the image will be resized.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Layout of the input.</p></li>
<li><p><strong>method</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Scale method to used [nearest_neighbor, linear, cubic].</p></li>
<li><p><strong>coordinate_transformation_mode</strong> (<em>string</em><em>, </em><em>optional</em>) – Describes how to transform the coordinate in the resized tensor
to the coordinate in the original tensor.
Refer to the ONNX Resize operator specification for details.
[half_pixel, align_corners, asymmetric]</p></li>
<li><p><strong>rounding_method</strong> (<em>string</em><em>, </em><em>optional</em>) – indicates how to find the “nearest” pixel in nearest_neighbor method
[round, floor, ceil]</p></li>
<li><p><strong>cubic_alpha</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – Spline Coefficient for cubic interpolation</p></li>
<li><p><strong>cubic_exclude</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Flag to exclude exterior of the image during cubic interpolation</p></li>
<li><p><strong>out_dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Type to return. If left None returns the same type as input.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The resized result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>relay.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.resize2d">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">resize2d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'linear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coordinate_transformation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'half_pixel'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rounding_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_exclude</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.resize2d" title="永久链接至目标">¶</a></dt>
<dd><p>图像 2 维重塑算子。</p>
<p>This operator takes data as input and does 2D scaling to the given scale factor.
In the default case, where the data_layout is <cite>NCHW</cite>
with data of shape (n, c, h, w)
out will have a shape (n, c, size[0], size[1])</p>
<p>method indicates the algorithm to be used while calculating the out value
and method can be one of (“linear”, “nearest_neighbor”, “cubic”)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>relay.Expr</em>) – The input data to the operator.</p></li>
<li><p><strong>size</strong> (<em>Tuple of Int</em><em> or </em><em>Expr</em>) – The out size to which the image will be resized.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Layout of the input.</p></li>
<li><p><strong>method</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Scale method to used [nearest_neighbor, linear, cubic].</p></li>
<li><p><strong>coordinate_transformation_mode</strong> (<em>string</em><em>, </em><em>optional</em>) – Describes how to transform the coordinate in the resized tensor
to the coordinate in the original tensor.
Refer to the ONNX Resize operator specification for details.
[half_pixel, align_corners, asymmetric]</p></li>
<li><p><strong>rounding_method</strong> (<em>string</em><em>, </em><em>optional</em>) – indicates how to find the “nearest” pixel in nearest_neighbor method
[round, floor, ceil]</p></li>
<li><p><strong>cubic_alpha</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – Spline Coefficient for bicubic interpolation</p></li>
<li><p><strong>cubic_exclude</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Flag to exclude exterior of the image during bicubic interpolation</p></li>
<li><p><strong>out_dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Type to return. If left None returns the same type as input.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The resized result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>relay.Expr</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.relay.image.resize3d">
<span class="sig-prename descclassname"><span class="pre">tvm.relay.image.</span></span><span class="sig-name descname"><span class="pre">resize3d</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">layout</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'NCDHW'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'linear'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">coordinate_transformation_mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'half_pixel'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rounding_method</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">-</span> <span class="pre">0.5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cubic_exclude</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">out_dtype</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.relay.image.resize3d" title="永久链接至目标">¶</a></dt>
<dd><p>图像 3 维重塑算子。</p>
<p>This operator takes data as input and does 3D scaling to the given scale factor.
In the default case, where the data_layout is <cite>NCDHW</cite>
with data of shape <cite>(n, c, d, h, w)</cite>
out will have a shape <cite>(n, c, size[0], size[1], size[2])</cite></p>
<p>method indicates the algorithm to be used while calculating the out value
and method can be one of (“linear”, “nearest_neighbor”, “cubic”)</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>data</strong> (<em>relay.Expr</em>) – The input data to the operator.</p></li>
<li><p><strong>size</strong> (<em>Tuple of Int</em><em> or </em><em>Expr</em>) – The out size to which the image will be resized.</p></li>
<li><p><strong>layout</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Layout of the input.</p></li>
<li><p><strong>method</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Scale method to used [nearest_neighbor, linear, cubic].</p></li>
<li><p><strong>coordinate_transformation_mode</strong> (<em>string</em><em>, </em><em>optional</em>) – Describes how to transform the coordinate in the resized tensor
to the coordinate in the original tensor.
Refer to the ONNX Resize operator specification for details.
[half_pixel, align_corners, asymmetric]</p></li>
<li><p><strong>rounding_method</strong> (<em>string</em><em>, </em><em>optional</em>) – indicates how to find the “nearest” pixel in nearest_neighbor method
[round, floor, ceil]</p></li>
<li><p><strong>cubic_alpha</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.10)"><em>float</em></a>) – Spline Coefficient for cubic interpolation</p></li>
<li><p><strong>cubic_exclude</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a>) – Flag to exclude exterior of the image during cubic interpolation</p></li>
<li><p><strong>out_dtype</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><em>optional</em>) – Type to return. If left None returns the same type as input.</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>result</strong> – The resized result.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>relay.Expr</p>
</dd>
</dl>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="transform.html" class="btn btn-neutral float-right" title="tvm.relay.transform" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="vision.html" class="btn btn-neutral float-left" title="tvm.relay.vision" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>